package edu.zut.cs.software.perfect.process.service.impl;

import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import edu.zut.cs.software.perfect.base.service.impl.GenericTreeManagerImpl;
import edu.zut.cs.software.perfect.process.dao.ProcessRegistrarDao;
import edu.zut.cs.software.perfect.process.domain.CourseProcess;
import edu.zut.cs.software.perfect.process.domain.ProcessRegistrar;
import edu.zut.cs.software.perfect.process.service.ProcessRegistrarManager;

/**
 * @ClassName ProcessRegistrarManagerImpl
 * @Description TODO
 * @Author niu-xi
 * @Date 2020年5月29日 下午11:11:48
 * @Version 1.0
 */
@Service(value = "processRegistrarManager")
@Transactional
public class ProcessRegistrarManagerImpl extends GenericTreeManagerImpl<ProcessRegistrar, Long> implements ProcessRegistrarManager{

	ProcessRegistrarDao processRegistrarDao;

	@Autowired
	public void setProcessRegistrarDao(ProcessRegistrarDao processRegistrarDao) {
		this.processRegistrarDao = processRegistrarDao;
		this.treeDao=this.processRegistrarDao;
		this.dao=this.processRegistrarDao;
	}
	
	@Override
	public List<ProcessRegistrar> findAll() {
		return (List<ProcessRegistrar>) this.dao.findAll();
	}

	@Override
	public Optional<ProcessRegistrar> findByCourseId(Long courseId) {
		Optional<ProcessRegistrar> result = this.dao.findById(courseId);
		return result;
	}

	@Override
	public Boolean deleteById(Long courseId) {
		Optional<ProcessRegistrar> processRegistrar = this.dao.findById(courseId);
		if(processRegistrar.equals(Optional.empty())) {
			return false;
		} else {
			this.dao.delete(processRegistrar.get());
			return true;
		}
	}

	
	
}
